#!/usr/bin/env node

console.log('hello scaffold!')

const inquirer = require('inquirer');
const path = require('path')
const fs =require('fs')
const ejs = require('ejs')

inquirer.prompt([{
    type:'input',
    name:'project',
    message:'Project Name?'
},{
    type:'input',
    name:'author',
    message:'Project Author?'
}])
.then(answers => {
    const tplDir = path.join(__dirname,'tpl')
    const destDir = process.cwd()
    fs.readdir(tplDir,(err,files)=>{
        if (err) throw err
        files.forEach(file => {
            ejs.renderFile(path.join(tplDir,file),answers,(error,result)=>{
                if(error) throw error
                fs.writeFileSync(path.join(destDir,file),result)
            })
        })
    })

})